package com.zhouxiaoge.枚举;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * @author 周明阳
 * mail:gqzmy@outlook.com
 * 时间:2018-04-12 11:25
 */

public class EnumTest {
    enum Size {
        SMALL("S"), MEDIUM("M"), LARGE("L"), EXTRA_LARGE("XL");

        private String abbreviation;

        public String getAbbreviation() {
            return abbreviation;
        }

        private Size(String abbreviation) {
            this.abbreviation = abbreviation;
        }
    }

    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        Size[] values = Size.values();
        for (Size value : values) {
            list.add(value.toString());
        }
        System.out.println("Enter a Size " + list + " :");
        Scanner scanner = new Scanner(System.in);
        String input = scanner.next().toUpperCase();

        Size size = Enum.valueOf(Size.class, input);
        System.out.println("Size: " + size + " " + size.ordinal());

        System.out.println("abbreviation= " + size.getAbbreviation());
        if (size == Size.EXTRA_LARGE) {
            System.out.println("Good job--you paid attention to the_.");
        }
    }
}
